<template>
  <div class="app-container">
    <div class="content">
      <!-- <div class="header">
        <span class="hname">账号:</span
        ><el-input v-model="input" placeholder="请输入个人账号"></el-input>
        <el-button type="warning">查询</el-button>
      </div> -->
      <div class="logoBox">
        <img src="@/assets/images/logo.png" alt="" />
      </div>
      <div class="rightHeader">
        <div class="header">
          <el-form
            :model="queryParams"
            ref="queryForm"
            size="large"
            :inline="true"
            label-width="125px"
          >
            <el-form-item label="事务类型:" prop="transactionTypeName">
              <el-select
                v-model="queryParams.transactionTypeName"
                multiple
                clearable
                placeholder="请选择事务类型,多选"
              >
                <el-option
                  v-for="item in optionsType"
                  :key="item.value"
                  :label="item.label"
                  :value="item.label"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="事务状态:" prop="statusName">
              <el-select
                v-model="queryParams.statusName"
                multiple
                clearable
                placeholder="请选择事务状态,多选"
              >
                <el-option
                  v-for="item in optionsStatus"
                  :key="item.value"
                  :label="item.label"
                  :value="item.label"
                >
                  <!-- <el-checkbox @change="changeSelect(item.label)">{{
                    item.label
                  }}</el-checkbox> -->
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="批号:" prop="lotAtt04">
              <el-input
                v-model="queryParams.lotAtt04"
                placeholder="请输入批号"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="货主(原始):" prop="fmCustomerId" class="Owner">
              <el-input
                v-model="queryParams.fmCustomerId"
                placeholder="请选择货主名称"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="产品代码(原始):" prop="fmSku">
              <el-input
                v-model="queryParams.fmSku"
                placeholder="请输入产品代码"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="库位编码(原始):" prop="fmLocation">
              <el-input
                v-model="queryParams.fmLocation"
                placeholder="请输入库位编码"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="跟踪号(原始):" prop="fmId">
              <el-input
                v-model="queryParams.fmId"
                placeholder="请输入跟踪号"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="货主(目标):" prop="toCustomerId" class="Owner">
              <el-input
                v-model="queryParams.toCustomerId"
                placeholder="请选择货主名称"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="产品代码(目标):" prop="toSku">
              <el-input
                v-model="queryParams.toSku"
                placeholder="请输入产品代码"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="库位编码(目标):" prop="toLocation">
              <el-input
                v-model="queryParams.toLocation"
                placeholder="请输入库位编码"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="跟踪号(目标):" prop="toId">
              <el-input
                v-model="queryParams.toId"
                placeholder="请输入跟踪号"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="事务时间:">
              <el-date-picker
                v-model="dateRange"
                style="width: 240px"
                value-format="yyyy-MM-dd"
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              ></el-date-picker>
            </el-form-item>
            <el-form-item class="searchButton">
              <el-button
                type="primary"
                icon="el-icon-search"
                size="small"
                @click="handleQuery"
                >搜索</el-button
              >
              <el-button
                type="primary"
                icon="el-icon-refresh"
                size="small"
                @click="resetQuery"
                >重置</el-button
              >
              <div class="footer">
                <img src="@/assets/images/back.png" alt="" @click="goBack" />
                <span @click="goBack">退出</span>
              </div>
            </el-form-item>
          </el-form>
        </div>
      </div>
      <!-- 810 -->
      <div class="wtable">
        <el-table
          :data="tableData"
          class="tableContent"
          height="710"
          v-loading="loading"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.8)"
          ><el-table-column
            fixed
            prop="hz"
            label="货主"
            width="150"
            align="center"
          >
          </el-table-column>
          <el-table-column
            fixed
            prop="sku"
            label="事务状态"
            width="150"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="skuDescr1"
            label="事务类型"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="alternateSku3"
            label="单证编号"
            width="150"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="qtyAvailed"
            label="单位"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="alternateSku4"
            label="FM产品"
            width="200"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="lotAtt04"
            label="目标产品"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="lotAtt04"
            label="FM产品描述(S)"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="lotAtt04"
            label="FM产品描述(L)"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="locationId"
            label="FM单位数量"
            width="150"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="dw"
            label="TO单位数量"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column prop="zl" label="FM规格" width="150" align="center">
          </el-table-column>
          <el-table-column
            prop="qtyAllocated"
            label="批号"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="qtyAllocated"
            label="FM生产厂家"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="qtyAllocated"
            label="FM库位"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="qtyAllocated"
            label="目标库位"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="qtyAllocated"
            label="事务时间"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="qtyAllocated"
            label="操作人"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="qtyAllocated"
            label="目标跟踪号"
            width="180"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="qtyAllocated"
            label="TO包装代码"
            width="180"
            align="center"
          >
          </el-table-column>
        </el-table>
        <div>
          <pagination
            v-show="total > 0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="handleQuery"
          />
        </div>
      </div>
    </div>
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      @close="dialogVisible = false"
    >
      <span>未查询到数据</span>
    </el-dialog>
    <!-- <ownerDig
      :dialogTableVisible="dialogTableVisible"
      @closeDialog="dialogcloseTab"
      @submitValue="submitfuValue"
    ></ownerDig> -->
    <!-- <ownerDig1
      :dialogTableVisible1="dialogTableVisible1"
      @closeDialog1="dialogcloseTab1"
      @submitValue1="submitfuValue1"
    ></ownerDig1> -->
  </div>
</template>

<script>
import { getTransaction } from "@/api/subSystem/continer";
// import ownerDig from "@/components/invenTrans/Owner";
// import ownerDig1 from "@/components/invenTrans/Owner1";
export default {
  // components: {
  //   ownerDig,
  //   ownerDig1,
  // },
  data() {
    return {
      // 事务类型
      optionsType: [
        {
          value: "90",
          label: "订单取消",
        },
        {
          value: "99",
          label: "订单关闭",
        },
        {
          value: "AD",
          label: "调整",
        },
        {
          value: "HD",
          label: "冻结加锁",
        },
        {
          value: "IN",
          label: "验收",
        },
        {
          value: "KT",
          label: "组装",
        },
        {
          value: "MV",
          label: "移动",
        },
        {
          value: "PA",
          label: "上架",
        },
        {
          value: "PK",
          label: "拣货",
        },
        {
          value: "PS",
          label: "拆分",
        },
        {
          value: "RK",
          label: "反拣",
        },
        {
          value: "RL",
          label: "冻结释放",
        },
        {
          value: "RP",
          label: "补货",
        },
        {
          value: "SO",
          label: "出货",
        },
        {
          value: "TR",
          label: "转移",
        },
        {
          value: "SC",
          label: "库位管控",
        },
        {
          value: "PO",
          label: "收货",
        },
      ],
      // 事务状态
      optionsStatus: [
        {
          value: "00",
          label: "创建",
        },
        {
          value: "10",
          label: "转移完成",
        },
        {
          value: "20",
          label: "冻结(等待中)",
        },
        {
          value: "90",
          label: "取消",
        },
        {
          value: "99",
          label: "完成",
        },
      ],
      // 日期范围
      dateRange: [],
      // 弹窗隐藏
      dialogVisible: false,
      // 总条数
      total: 0,
      //点击表格传的值
      nameData: "",
      loading: false,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        transactionTypeName: [],
        statusName: [],
        lotAtt04: null,
        fmCustomerId: null,
        fmSku: null,
        fmLocation: null,
        fmId: null,
        toCustomerId: null,
        toSku: null,
        toLocation: null,
        toId: null,
      },
      // queryRules: {
      //   skuDescr1: [
      //     { required: true, message: "请输入商品名称", trigger: "blur" },
      //     { min: 5, trigger: "blur" },
      //   ],
      //   lotAtt04: [
      //     { required: true, message: "请输入批号", trigger: "blur" },
      //     { min: 5, trigger: "blur" },
      //   ],
      //   locationId: [
      //     { required: true, message: "请输入库位", trigger: "blur" },
      //     { min: 5, trigger: "blur" },
      //   ],
      //   alternateSku2: [
      //     { required: true, message: "请输入69码", trigger: "blur" },
      //     { min: 5, trigger: "blur" },
      //   ],
      // },
      initialTableData: [], // 初始状态的表格数据
      tableData: [],
    };
  },
  methods: {
    // changeSelect(val) {
    //   const selectedOption = this.optionsStatus.find(
    //     (item) => item.label === val
    //   );
    //   if (
    //     selectedOption &&
    //     !this.queryParams.statusName.includes(selectedOption.label)
    //   ) {
    //     this.queryParams.statusName.push(selectedOption.label);
    //   }
    // },
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    goBack() {
      this.$router.push("/subSystem1");
    },
    handleQuery() {
      this.loading = true;
      const queryParamsString = {
        ...this.queryParams,
        transactionTypeName: this.queryParams.transactionTypeName.join(","),
        statusName: this.queryParams.statusName.join(","),
      };
      getTransaction(this.addDateRange(queryParamsString, this.dateRange))
        .then((res) => {
          console.log(111, queryParamsString);
          if (Array.isArray(res.rows) && res.rows.length > 0) {
            this.tableData = res.rows;
            this.total = res.total;
            this.loading = false;
          } else {
            this.tableData = res.rows;
            this.total = res.total;
            this.dialogVisible = true;
            this.loading = false;
          }
        })
        .catch((error) => {
          this.loading = false;
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.app-container {
  padding: 0 !important;
  width: 100%;
  height: 100%;
  background: url("~@/assets/images/bg.png") no-repeat;
  overflow: hidden;
  ::v-deep .el-form-item__label {
    color: #fff;
    font-size: 16px;
    font-weight: 400;
  }
  ::v-deep .el-input--small .el-input__inner {
    height: 40px;
  }
  ::v-deep .el-pagination__jump {
    color: #ffffff;
  }
  ::v-deep .el-pagination__total {
    color: #ffffff;
  }
  ::v-deep .el-pagination {
    margin-right: 78px;
  }
  .pagination-container {
    background: transparent;
    padding: 0px 20px !important;
    margin-top: 5px !important;
  }
  .content {
    height: 100%;
  }
  .logoBox {
    width: 200px;
    margin-left: 15px;
    img {
      width: 200%;
    }
  }
  .rightHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-left: 90px;
    margin-top: -15px;
    .header {
      .footer {
        display: flex;
        align-items: center;
        cursor: pointer;
        margin-top: -50px;
        margin-left: 200px;
        color: #ffffff5d;
        font-size: 18px;
        img {
          width: 30%;
        }
        span {
          display: block;
          margin-left: -40px;
          margin-top: 15px;
          font-size: 12px;
        }
      }
    }
  }
  .hname {
    width: 40px;
  }
  .el-button--medium {
    margin-left: 10px;
    font-size: 18px;
  }
  .wtable {
    width: 100%;
    text-align: center;
  }
  .tableContent {
    margin: 0 auto;
    width: 96%;
    margin-top: 0px;
  }
  ::v-deep .el-form-item__label {
    color: #fff;
  }
  ::v-deep .el-input {
    width: 90%;
    font-size: 16px;
  }
  ::v-deep .el-dialog:not(.is-fullscreen) {
    margin-top: 40vh !important;
  }
  ::v-deep .el-input--suffix .el-input__inner {
    padding-right: 0px;
  }
  ::v-deep .el-pagination.is-background .btn-next:disabled {
    color: #797a7b;
  }
  ::v-deep .el-pagination.is-background .btn-prev:disabled {
    color: #797a7b;
  }
  ::v-deep .el-pagination span:not([class*="suffix"]) {
    min-width: 56.5px;
  }
  ::v-deep .el-form--inline .el-form-item {
    margin-right: 0;
  }
  ::v-deep .el-button--small {
    padding: 12px 15px;
    font-size: 14px;
  }
  .timestyle {
    width: 211px;
    padding-right: 20px;
  }
  .searchButton {
    margin-left: 10px;
  }
  ::v-deep .el-table__empty-block {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
  }
  .Owner {
    position: relative;
    // ::v-deep .el-icon-more:before {
    //   position: absolute;
    //   left: 160px;
    //   top: 13px;
    //   cursor: pointer;
    // }
    ::v-deep .custom-icon {
      position: absolute;
      left: 160px;
      top: 5px;
      width: 30px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      display: inline-block;
      cursor: pointer;
    }
  }
  ::v-deep .el-select__tags {
    flex-wrap: nowrap !important;
    overflow: hidden;
  }
}
</style>